#include <iostream>
#include <string>
using namespace std;

#include "Server.h"
using namespace yazi::server;

#include "System.h"
#include "IniFile.h"
#include "Singleton.h"
using namespace yazi::utility;



int main(){
    System* sys = Singleton<System>::instance();
    sys->init();
    // cout << sys->get_root_path() << endl;

    IniFile* ini = Singleton<IniFile>::instance();
    const string ip = (*ini)["server"]["ip"];
    int port = (*ini)["server"]["port"];
    int threads = (*ini)["server"]["threads"];
    int max_conn = (*ini)["server"]["max_conn"];
    int wait_time = (*ini)["server"]["wait_time"];
    // cout << port << " " << threads << " " << max_conn << " " << wait_time << endl;

    Server* server = Singleton<Server>::instance();  
    server->set_threads(threads);
    server->set_max_conn(max_conn);
    server->set_wait_time(wait_time);

    server->listen(ip, port);
    server->start();
    return 0;
}